<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>监视器使用举例</title>
</head>
<body>

<div id="app">
    <div>
         问题:<input v-model="question">
    </div>
    <div>
         答案:{{answer}}
    </div>

</div>
</body>
<script src="../../../lib/vue.global.js"></script>
<script>

    const app = {
        data(){ // data:function(){}
             return {
                  question:'',
                   answer:''
             }
        },mounted(){

            $.ajax({
                 success:(data)=>{
                      this.answer = data;
                 }
            })
        }

        ,watch:{
             question:function (question) {

                  let that = this;

                 // setTimeout(function () {
                 //     that.answer = "the question of "+ question +"is ...."; // this指向匿名函数的作用域空间
                 // },2000)

                 setTimeout(()=>{
                     this.answer = "the question of "+ question +"is ....";
                 },2000)

                 this.answer = "waiting.....";


             }
        }
    }

Vue.createApp(app).mount('#app')

</script>

</html>